#!/bin/sh -e

# Generate the table of contents
cat Tutorial.md | \
  awk -f tags.awk | \
  awk -f sections.awk | \
  awk -f toc.awk \
  > toc.md

# Generate the final Markdown file
cat Tutorial.md | \
  awk -f tags.awk | \
  awk -f sections.awk | \
  awk -f include.awk \
  > ../Tutorial.md

# Check for broken refs in the final Markdown file
./check-refs ../Tutorial.md
